package misc;

import java.security.MessageDigest;

public class Utility {
    
    public static String hashMD5(String word)
    {
        try
        {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] bytes = word.getBytes("UTF-8");
            byte[] messageDigest = md.digest(bytes);

            StringBuffer hexString = new StringBuffer();
            for (int i=0;i<messageDigest.length;i++) {
                hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
            }

            return hexString.toString();
        }
        catch(Exception e)
        {
            Logger.write(e.getMessage(),Logger.LogType.error);
        }

        return null;
    }
}
